package cn.zn.modules.signature.service.impl;

import cn.hutool.core.util.StrUtil;
import cn.zn.framework.common.utils.PageUtils;
import cn.zn.modules.signature.dao.HtmlsignatureDao;
import cn.zn.modules.signature.entity.HtmlsignatureEntity;
import cn.zn.modules.signature.service.HtmlsignatureService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("htmlsignatureService")
public class HtmlsignatureServiceImpl extends ServiceImpl<HtmlsignatureDao, HtmlsignatureEntity> implements HtmlsignatureService {

    @Override
    public PageUtils queryPage(HtmlsignatureEntity htmlsignature, IPage<HtmlsignatureEntity> page) {

        QueryWrapper<HtmlsignatureEntity> htmlsignatureQueryWrapper = Wrappers.query();
        if (StrUtil.isNotBlank(htmlsignature.getDocumentId())) {
            htmlsignatureQueryWrapper.eq("document_id", htmlsignature.getDocumentId());
        }
        IPage<HtmlsignatureEntity> pageResult = this.page(page, htmlsignatureQueryWrapper);
        return new PageUtils(pageResult);
    }

    @Override
    public List<HtmlsignatureEntity> findSigns(String applyCode) {
        QueryWrapper<HtmlsignatureEntity> queryWrapper = Wrappers.query();
        queryWrapper.eq("document_id",applyCode);
        return this.baseMapper.selectList(queryWrapper);
    }

}